package com.team1.supervend.domain;

import java.util.HashMap;

import com.team1.supervend.domain.ProductDescription;

public class ProductInventory {
// todo	private double quantity;
// todo	private double minQuantity;
// todo	private boolean belowMin;
	private HashMap<ItemID, ProductDescription> productDescriptions = new HashMap<ItemID, ProductDescription>(); 

	// start of sample product inventory data
	private ItemID    id1;
	private Money   cost1;
	private String descr1;
	
	private ItemID    id2;
	private Money   cost2;
	private String descr2;

	private ItemID    id3;
	private Money   cost3;
	private String descr3;

	private ItemID    id4;
	private Money   cost4;
	private String descr4;

	private ItemID    id5;
	private Money   cost5;
	private String descr5;

	private ItemID    id6;
	private Money   cost6;
	private String descr6;

	private ItemID    id7;
	private Money   cost7;
	private String descr7;

	private ItemID    id8;
	private Money   cost8;
	private String descr8;

	private ItemID    id9;
	private Money   cost9;
	private String descr9;
	// end of sample product inventory data
	
	
	public ProductInventory() {
		//System.out.println("New ProductInventory");
	}

	public void ProvideProductInventory() {
		//System.out.println("Setting id, cost, and description for each item to be sent to SuperVend for stocking");
		// start of sample product inventory data
		id1    = new ItemID( 1 );
		cost1  = new Money( 0.60f );
		descr1 = "Dentyne gum";
		
		id2    = new ItemID( 2 );
		cost2  = new Money( 1.50f );
		descr2 = "Coke drink";

		id3    = new ItemID( 3 );
		cost3  = new Money( 2.50f );
		descr3 = "Doritos chips";

		id4    = new ItemID( 4 );
		cost4  = new Money( 4.0f );
		descr4 = "Band-aid bandages";

		id5    = new ItemID( 5 );
		cost5  = new Money( 5.0f );
		descr5 = "product5";

		id6    = new ItemID( 6 );
		cost6  = new Money( 6.0f );
		descr6 = "product6";

		id7    = new ItemID( 7 );
		cost7  = new Money( 7.0f );
		descr7 = "product7";

		id8    = new ItemID( 8 );
		cost8  = new Money( 8.0f );
		descr8 = "product8";

		id9    = new ItemID( 9 );
		cost9  = new Money( 9.0f );
		descr9 = "product9";
		// end of sample product inventory data
	}
	
	public void StockProductInventory() {
		ProductDescription desc;

		//System.out.println("Stocking ProductInventory in SuperVend");
		// start loading sample product inventory data in productDescriptions HashMap
		desc = new ProductDescription( id1, cost1, descr1 );
		productDescriptions.put( id1, desc);

		desc = new ProductDescription( id2, cost2, descr2 );
		productDescriptions.put( id2, desc);
		
		desc = new ProductDescription( id3, cost3, descr3 );
		productDescriptions.put( id3, desc);

		desc = new ProductDescription( id4, cost4, descr4 );
		productDescriptions.put( id4, desc);
		
		desc = new ProductDescription( id5, cost5, descr5 );
		productDescriptions.put( id5, desc);

		desc = new ProductDescription( id6, cost6, descr6 );
		productDescriptions.put( id6, desc);
		
		desc = new ProductDescription( id7, cost7, descr7 );
		productDescriptions.put( id7, desc);

		desc = new ProductDescription( id8, cost8, descr8 );
		productDescriptions.put( id8, desc);
		
		desc = new ProductDescription( id9, cost9, descr9 );
		productDescriptions.put( id9, desc);
		// finished loading sample product inventory data in productDescriptions HashMap

	}
	
	public void printProductDescriptions( ) {
		System.out.println("Available Items");
		System.out.println("---------------- ");
		
		System.out.println("");
		productDescriptions.get( id1 ).PrintDescription();
		System.out.println("");

		productDescriptions.get( id2 ).PrintDescription();
		System.out.println("");

		productDescriptions.get( id3 ).PrintDescription();
		System.out.println("");

		productDescriptions.get( id4 ).PrintDescription();
		System.out.println("");

		return ;
	}

	public HashMap<ItemID, ProductDescription> getProductDescriptions( ) {
		return productDescriptions;
	}

	public ProductDescription getProductDescription( ItemID id ) {
		return productDescriptions.get( id );
	}

	public ItemID getItemID( int id ) {
		ItemID itemID;
		if ( id == 1 ){
			itemID = id1;
		}
		else if ( id == 2 ){
			itemID = id2;
		}
		else if ( id == 3 ){
			itemID = id3;
		}
		else if ( id == 4 ){
			itemID = id4;
		}
		else if ( id == 5 ){
			itemID = id5;
		}
		else if ( id == 6 ){
			itemID = id6;
		}
		else if ( id == 7 ){
			itemID = id7;
		}
		else if ( id == 8 ){
			itemID = id8;
		}
		else if ( id == 9 ){
			itemID = id9;
		}
		else {
			itemID = null;
		}
		return itemID;
	}

}
